package com;

import com.RedisClientTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.ShardedJedis;

import java.io.InputStream;
import java.util.Properties;
import java.util.*;
public class TEST {

    public static void main(String[] args) {
      ApplicationContext ac =  new ClassPathXmlApplicationContext("classpath:/data-source.xml");
        RedisClientTemplate redisClient = (RedisClientTemplate)ac.getBean("redisClientTemplate");
        redisClient.set("a", "abc");
        redisClient.lpush("list1","dhdg");
        System.out.println("连接成功: "+redisClient.get("a")+"  lpush: "+redisClient.lrange("list1",0,1));

      /*  Jedis jedis = new Jedis("127.0.0.1",6379);
        jedis.auth("rmkjreis");
        //Redis Java String(字符串) 实例
        jedis.set("tutorial", "cccc");
        System.out.println(jedis.get("tutorial"));
        System.out.println("Server is running: "+jedis.ping());
        //Redis Java List(列表) 实例
        //存储数据到列表中
        jedis.lpush("tutorial-list", "Redis");
        jedis.lpush("tutorial-list", "Mongodb");
        jedis.lpush("tutorial-list", "Mysql");
        // 获取存储的数据并输出
        List<String> list = jedis.lrange("tutorial-list", 0 ,5);
        for(int i=0; i<list.size(); i++) {
            System.out.println("Stored string in redis:: "+list.get(i));
        }
*/

    }
}
